const express = require("express")
const app = express()
const Goods = require('../service/goods')




app.get("/getgoods", async (req, res) => {
    let result = await Goods.getGoods()
    // console.log(result);
    res.send(result)
})
app.get("/getgoodstype", async (req, res) => {
    console.log(req.query);
    let result = await Goods.getGoodstype(req.query.type)
    // console.log(result);
    res.send(result)
})
app.get("/getgoodsimformation", async (req, res) => {
    console.log(req.query);
    let result = await Goods.getgoodsimformation(req.query.id)
    // console.log(result);
    res.send(result)
})

app.get("/addgoods", async (req, res) => {
    // console.log(req.query);
    let result = await Goods.addGoods(req.query.name,req.query.type,req.query.price)
    // console.log(result);
    res.send(result)
})


app.get("/deletegoods", async (req, res) => {
    console.log(req.query);
    let result = await Goods.addGoods(req.query.name,req.query.type,req.query.price)
    console.log(result);
    res.send(result)  
})
module.exports = app;
